<template>
  <div>
    <TopFilter :list="topFilterList" :cols="4" labelWidth="80" @filterChange="changeHandle" @onCollapse="handleTableFilterCollapse"></TopFilter>
    <FilterTable
      ref="table"
      columnsRef="partPartInfoManagePartInfoIndex"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'rows'"
      selectionType="single"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="handleTableRowSelect"
      :onSyncTableData="columns => (this.syncTableList = columns)"
      :isExportExcel="true"
      exportFileName="配件主文件.xlsx"
      :onCalcExportData="handleExportFun"
    >
      <template slot="controls">
        <el-button size="small" type="primary" icon="el-icon-plus" @click="addHandle">新增</el-button>
        <el-button size="small" type="primary" @click="copyHandler">复制</el-button>
        <el-button size="small" type="primary" @click="adjustment">统一调整</el-button>
        <el-button size="small" type="primary" @click="showR3Price">R3价格下发</el-button>
        <el-button size="small" type="primary" @click="setMealStryctureVisible = true">套餐结构</el-button>
        <!-- <el-button size="small" type="primary" :loading="exportLoading" @click="outExe()">导出</el-button> -->
      </template>
    </FilterTable>
    <!-- 新建编辑页面 -->
    <Drawer width="75%" :visible.sync="visible" destroyOnClose :title="dialogTitle" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px', position: 'realtive' }">
      <createPart :type="handleType" :rowData="formData" @close="closeHandler" />
    </Drawer>
    <!-- 替换件 -->
    <BaseDialog :visible.sync="replacePartDialogVisible" destroyOnClose title="查看替换件" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <replacePartSelect :partNo="rowDataPartNo" :optionNo="rowDataOptionNo" @close="replacePartDialogVisible = false" />
    </BaseDialog>
    <!-- r3价格下发 -->
    <BaseDialog :visible.sync="r3PriceDownloadVisible" destroyOnClose title="r3价格下发" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <r3PriceDownload @close="r3PriceDownloadVisible = false" />
    </BaseDialog>
    <!-- 统一调整抽屉 -->
    <Drawer :visible.sync="adjustmentVisible" destroyOnClose title="统一调整" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <adjustment @close="adjustmentVisible = false" />
    </Drawer>
    <!-- 套餐结构 -->
    <Drawer :visible.sync="setMealStryctureVisible" destroyOnClose title="查看套餐结构" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <setMealStrycture @close="setMealStryctureVisible = false" />
    </Drawer>
  </div>
</template>

<script>
import { getBrand } from '@/api/repair/basicParameters';
// import { findAllRepair, getBrand } from '@/api/repair/basicParameters';
import { findAllRepair } from '@/api/repair/basicParameters';
import moment from 'moment';
import { queryPartInfos, partExport, queryUnitCode } from '@/api/part/partInfo';
import { getBrandList } from '@/api/common/cars/masterDataCars';
import { dictionary } from '@/utils/dictMixin';
import { arrayObjDeWeight, messageAction, exportExcelFile, notifyAction } from '@/utils';

import createPart from './createPart';
import replacePartSelect from './replacePartSelect';
import r3PriceDownload from './r3PriceDownload';
import setMealStrycture from './setMealStrycture';
import adjustment from './adjustment';

export default {
  name: 'partPartinfoManagePartinfo',
  components: {
    createPart,
    replacePartSelect,
    r3PriceDownload,
    setMealStrycture,
    adjustment
  },
  mixins: [dictionary],
  data() {
    this.conf = { add: '新增', edit: '编辑', show: '显示' };
    return {
      topFilterList: this.createTopFilterList(),
      fetchApi: queryPartInfos,
      fetchParams: { pageNum: 1, xhrAbort: true },
      visible: false,
      dialogTitle: '',
      syncTableList: [],
      columns: this.createTableColumns(),
      handleType: '',
      exportLoading: false,
      formData: {},
      replacePartDialogVisible: false,
      rowDataPartNo: '', // 查看替换件时的配件代码
      rowDataOptionNo: '', // 查看替换件时多传的参数
      selectedRowData: {}, // 选中的行项数据
      r3PriceDownloadVisible: false, // 是否显示更新r3价格
      adjustmentVisible: false, // 是否显示统一调整抽屉
      setMealStryctureVisible: false, // 是否显示套餐结构
      unitCodeData: {} // 单位数据(翻译用)
    };
  },
  created() {
    // this.getBrand();
    this.queryAllUnitCode();
  },
  mounted() {
    this.getBrand();
    // this.queryDefaultPa();
  },
  methods: {
    createTopFilterList() {
      return [
        {
          type: 'INPUT',
          label: '主组号',
          fieldName: 'mainGroupNo'
        },
        {
          type: 'INPUT',
          label: '配件代码',
          fieldName: 'partNo',
          placeholder: '配件代码...'
          // rules: [
          //   { required: true, message: '请输入配件代码', trigger: 'blur' },
          //   { min: 2, message: '请输入至少两位配件代码', trigger: 'change' }
          // ]
        },
        {
          type: 'INPUT',
          label: '配件说明',
          fieldName: 'partName',
          placeholder: '请输入...'
        },
        {
          type: 'SELECT',
          label: '品牌',
          fieldName: 'brand',
          placeholder: '请选择...',
          itemList: []
        },
        {
          type: 'SELECT',
          label: '数据来源',
          fieldName: 'oemTag',
          placeholder: '请选择...',
          itemList: this.createDictList('1045')
        },
        // {
        //   type: 'SELECT',
        //   label: '是否附件',
        //   fieldName: 'isAccessory',
        //   placeholder: '请选择...',
        //   itemList: this.createDictList('1004')
        // },
        // {
        //   type: 'SELECT',
        //   label: '是否CCC配件',
        //   fieldName: 'isCccPart',
        //   placeholder: '请选择...',
        //   render: props => {
        //     return (
        //       <el-tag type={props.row.isAccessory === 80991001 ? 'success' : 'primary'} close-transition>
        //         {this.createDictText(props.row.isAccessory, '8099')}
        //       </el-tag>
        //     );
        //   }
        // },
        // {
        //   type: 'INPUT',
        //   label: '备注',
        //   fieldName: 'remark',
        //   placeholder: '请输入...'
        // },
        {
          type: 'RANGE_DATE',
          label: '更新日期',
          fieldName: 'begin|end',
          placeholder: '更新日期...',
          valueFormat: 'yyyy-MM-dd'
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 180,
          fixed: 'left',
          render: props => {
            return (
              <div>
                <el-button size="mini" disabled={props.row.oemTag == 10451002} type="text" onClick={() => this.editHandle(props.row)}>
                  编辑
                </el-button>
                <el-button size="mini" type="text" onClick={() => this.showReplacePart(props.row)}>
                  查看替换件
                </el-button>
              </div>
            );
            // <el-button size="mini" type="text" onClick={() => this.showHandle(props.row)}>
            //   明细
            // </el-button>
          }
        },
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '配件代码',
          dataIndex: 'partNo',
          width: 150,
          sorter: true,
          filter: true,
          showOverflowTooltip: true,
          filterType: 'input'
        },
        {
          title: '配件名称',
          dataIndex: 'partDescription',
          sorter: true,
          filter: true,
          width: 150,
          showOverflowTooltip: true,
          filterType: 'input'
        },
        {
          title: '配件说明',
          dataIndex: 'partName',
          sorter: true,
          filter: true,
          width: 150,
          showOverflowTooltip: true,
          filterType: 'input'
        },
        {
          title: '最小包装数',
          dataIndex: 'packageLiaght',
          sorter: true,
          filter: true,
          align: 'right',
          precision: 2,
          filterType: 'number'
        },
        {
          title: 'ABC分类',
          dataIndex: 'abcType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('8092'),
          dictItems: this.createDictList('8092'),
          render: props => {
            // console.log(props.row);
            return <span>{this.createDictText(props.row.abcType, '8092')}</span>;
          }
        },
        {
          title: '配件分类代码',
          dataIndex: 'partSortCode',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('8106'),
          dictItems: this.createDictList('8106'),
          render: params => {
            return <span>{this.createDictText(params.row.partSortCode, '8106')}</span>;
          }
        },
        {
          title: '品牌',
          dataIndex: 'brandName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车系',
          dataIndex: 'seriesName',
          sorter: true,
          filter: true,
          filterType: 'input',
          showOverflowTooltip: true
        },
        {
          title: '车型',
          dataIndex: 'modelName',
          sorter: true,
          filter: true,
          filterType: 'input',
          showOverflowTooltip: true
        },
        {
          title: '包装单位',
          dataIndex: 'packageUnit',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('8105'),
          dictItems: this.createDictList('8105'),
          render: params => {
            return <span>{this.createDictText(params.row.packageUnit, '8105')}</span>;
            // return <span>{this.unitCodeData[params.row.packageUnit]}</span>;
          }
        },
        {
          title: '不含税采购单价',
          dataIndex: 'planPrice',
          sorter: true,
          filter: true,
          align: 'right',
          precision: 2,
          filterType: 'number'
        },
        {
          title: '加价率',
          dataIndex: 'priceAddRate',
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '销售单价',
          dataIndex: 'costSalesPrice',
          sorter: true,
          filter: true,
          align: 'right',
          precision: 2,
          filterType: 'number'
        },
        {
          title: '批发单价',
          dataIndex: 'costWholesalesPrice',
          sorter: true,
          filter: true,
          align: 'right',
          precision: 2,
          filterType: 'number'
        },
        // {
        //   title: '出库单价',
        //   dataIndex: 'costOutPrice',
        //   sorter: true,
        //   filter: true,
        //   align: 'right',
        //   precision: 2,
        //   filterType: 'number'
        // },
        {
          title: '常用件',
          dataIndex: 'isCommonPart',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          dictItems: this.createDictList('1004'),
          render: props => {
            return (
              <el-tag type={props.row.isCommonPart === 10041001 ? 'success' : 'primary'} close-transition>
                {this.createDictText(props.row.isCommonPart, '1004') || '否'}
              </el-tag>
            );
          }
        },
        {
          title: '成套件',
          dataIndex: 'isKitPart',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          dictItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.isKitPart, '1004')}</span>;
          }
        },
        {
          title: '呆滞天数',
          dataIndex: 'sluggishDays',
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '二维码激活',
          dataIndex: 'qrActive',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          dictItems: this.createDictList('1004'),
          render: props => {
            return (
              <el-tag type={props.row.qrActive === 10041001 ? 'success' : 'primary'} close-transition>
                {this.createDictText(props.row.qrActive, '1004') || '否'}
              </el-tag>
            );
          }
        },

        {
          title: '套餐',
          dataIndex: 'isPackage',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          dictItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.isPackage, '1004')}</span>;
          }
        },
        {
          title: '配件类型',
          dataIndex: 'partType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('5000'),
          dictItems: this.createDictList('5000'),
          render: props => {
            return <span>{props.row.partType ? this.createDictText(props.row.partType, '5000') : ''}</span>;
          }
        },
        {
          title: '创建时间',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '更新时间',
          dataIndex: 'updatedAt',
          sorter: true,
          filter: true,
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '价格更新时间',
          dataIndex: 'priceUpdate',
          sorter: true,
          filter: true,
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '常规订货单价',
          dataIndex: 'regularPrice',
          sorter: true,
          filter: true,
          align: 'right',
          precision: 2,
          filterType: 'number'
        },
        // {
        //   title: '网点价',
        //   dataIndex: 'nodePrice',
        //   filter: true,
        //   filterType: 'number'
        // },
        // {
        //   title: '销售限价',
        //   dataIndex: 'limitPrice',
        //   align: 'right',
        //   precision: 2,
        //   filter: true,
        //   filterType: 'number'
        // },
        // {
        //   title: '索赔价',
        //   dataIndex: 'claimPrice',
        //   align: 'right',
        //   precision: 2,
        //   filter: true,
        //   filterType: 'number'
        // },
        // {
        //   title: '终端建议零售价格',
        //   dataIndex: 'insurancePrice',
        //   align: 'right',
        //   precision: 2,
        //   filter: true,
        //   filterType: 'number'
        // },
        // {
        //   title: '产地',
        //   dataIndex: 'oriProCode',
        //   filter: true,
        //   filterType: 'input'
        // },
        {
          title: '替代配件',
          dataIndex: 'optionNo',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '停用',
          dataIndex: 'isDisable',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('8131'),
          dictItems: this.createDictList('8131'),
          render: props => {
            return <span>{this.createDictText(props.row.isDisable, '8131')}</span>;
          }
        },
        {
          title: '停用时间',
          dataIndex: 'disableDate',
          sorter: true,
          filter: true,
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '激活停用',
          dataIndex: 'isActivate',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('8131'),
          dictItems: this.createDictList('8131'),
          render: props => {
            return <span>{this.createDictText(props.row.isActivate, '8131')}</span>;
          }
        },
        {
          title: '激活停用时间',
          dataIndex: 'activateDate',
          sorter: true,
          filter: true,
          filterType: 'date-range'
        },
        {
          title: 'CCC件',
          dataIndex: 'isCccPart',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('8099'),
          dictItems: this.createDictList('8099'),
          render: props => {
            return <span>{this.createDictText(props.row.isCccPart, '8099')}</span>;
          }
        },
        {
          title: '是否附件',
          dataIndex: 'isAccessory',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          dictItems: this.createDictList('1004'),
          render: props => {
            if (props.row.isAccessory) {
              return (
                <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
                  {this.createDictText(props.row.isAccessory, '1004')}
                </el-tag>
              );
            } else {
              return <span></span>;
            }
          }
        },
        {
          title: '备注',
          dataIndex: 'remark',
          sorter: true,
          filter: true,
          filterType: 'input',
          showOverflowTooltip: true
        },

        {
          title: '体积标识',
          dataIndex: 'volumeMark',
          sorter: true,
          filter: true,
          filterType: 'input'
          // render: props => {
          //   return (
          //     <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
          //       {this.createDictText(props.row.isAccessory, '1004')}
          //     </el-tag>
          //   );
          // }
        },
        {
          title: '体积',
          dataIndex: 'volume',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '体积单位',
          dataIndex: 'volumeUnit',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '重量标识',
          dataIndex: 'weightMark',
          sorter: true,
          filter: true,
          filterType: 'input'
          // render: props => {
          //   return (
          //     <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
          //       {this.createDictText(props.row.isAccessory, '1004')}
          //     </el-tag>
          //   );
          // }
        },
        {
          title: '重量',
          dataIndex: 'weight',
          sorter: true,
          filter: true,
          align: 'right',
          precision: 2,
          filterType: 'number'
        },
        {
          title: '重量单位',
          dataIndex: 'weightUnit',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '保质期标识',
          dataIndex: 'shelfLiftMark',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', value: 1 },
            { text: '否', value: 0 }
          ],
          dictItems: [
            { text: '是', value: 1 },
            { text: '否', value: 0 }
          ],
          render: props => {
            // return (
            //   <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
            //     {this.createDictText(props.row.isAccessory, '1004')}
            //   </el-tag>
            // );
            return <el-checkbox disabled={true} checked={props.row.saleLockMark == 1}></el-checkbox>;
          }
        },
        {
          title: '采购锁标识',
          dataIndex: 'stockLockMark',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', value: 1 },
            { text: '否', value: 0 }
          ],
          dictItems: [
            { text: '是', value: 1 },
            { text: '否', value: 0 }
          ],
          render: props => {
            // return (
            //   <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
            //     {this.createDictText(props.row.isAccessory, '1004')}
            //   </el-tag>
            // );
            return <el-checkbox disabled={true} checked={props.row.saleLockMark == 1}></el-checkbox>;
          }
        },
        {
          title: '销售锁标识',
          dataIndex: 'saleLockMark',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', value: 1 },
            { text: '否', value: 0 }
          ],
          dictItems: [
            { text: '是', value: 1 },
            { text: '否', value: 0 }
          ],
          render: props => {
            // return (
            //   <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
            //     {this.createDictText(props.row.isAccessory, '1004')}
            //   </el-tag>
            // );
            return <el-checkbox disabled={true} checked={props.row.saleLockMark == 1}></el-checkbox>;
          }
        },
        {
          title: '开口件代码',
          dataIndex: 'openCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: 'FIB标识',
          dataIndex: 'fibMark',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', value: 'X' },
            { text: '否', value: 0 }
          ],
          dictItems: [
            { text: '是', value: 'X' },
            { text: '否', value: 0 }
          ],
          render: props => {
            if (props.row.fibMark == 'X') {
              return <input type="checkbox" checked disabled />;
            } else {
              return <input type="checkbox" disabled />;
            }
          }
          // render: props => {
          //   // return (
          //   //   <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
          //   //     {this.createDictText(props.row.isAccessory, '1004')}
          //   //   </el-tag>
          //   // );
          //   return <el-checkbox disabled={true} chekced={props.row.fibMark == 1}></el-checkbox>;
          // }
        },
        {
          title: '是否在EOP',
          dataIndex: 'isEop',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', value: 1 },
            { text: '否', value: 0 }
          ],
          dictItems: [
            { text: '是', value: 1 },
            { text: '否', value: 0 }
          ],
          render: props => {
            // return (
            //   <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
            //     {this.createDictText(props.row.isAccessory, '1004')}
            //   </el-tag>
            // );
            return <el-checkbox disabled={true} checked={props.row.isEop == 1}></el-checkbox>;
          }
        },
        {
          title: '佣金组',
          dataIndex: 'commissGroup',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '厂家建议不含税零售价',
          dataIndex: 'referPrice',
          sorter: true,
          filter: true,
          align: 'right',
          precision: 2,
          filterType: 'number'
        },
        {
          title: '新能源标识',
          dataIndex: 'isEnergy',
          sorter: true,
          filter: true,
          filterType: 'input'
          // render: props => {
          //   return (
          //     <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
          //       {this.createDictText(props.row.isAccessory, '1004')}
          //     </el-tag>
          //   );
          // }
        },
        {
          title: '个性化件',
          dataIndex: 'personOrderMark',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', value: 'X' },
            { text: '否', value: 0 }
          ],
          dictItems: [
            { text: '是', value: 'X' },
            { text: '否', value: 0 }
          ],
          render: props => {
            if (props.row.personOrderMark == 'X') {
              return <input type="checkbox" checked disabled />;
            } else {
              return <input type="checkbox" disabled />;
            }
          }
          //  props => {
          //   return <el-checkbox disabled={true} chekced={props.row.personOrderMark == 'X'}></el-checkbox>;
          // }
        },
        {
          title: '三方订单件',
          dataIndex: 'thirdOrderMark',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', value: 'X' },
            { text: '否', value: 0 }
          ],
          dictItems: [
            { text: '是', value: 'X' },
            { text: '否', value: 0 }
          ],
          render: props => {
            if (props.row.thirdOrderMark == 'X') {
              return <input type="checkbox" checked disabled />;
            } else {
              return <input type="checkbox" disabled />;
            }
          }
          // props => {
          //   return <el-checkbox disabled={true} chekced={!props.row.thirdOrderMark == 'X'}></el-checkbox>;
          // }
        },
        {
          title: '原厂标识',
          dataIndex: 'downTag',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', value: 'x' },
            { text: '否', value: 0 }
          ],
          dictItems: this.createDictList('1004'),
          render: props => {
            return <el-checkbox disabled={true} checked={props.row.downTag == '10041001'}></el-checkbox>;
          }
        },
        {
          title: '仅辖区库发货标识',
          dataIndex: 'shipMark',
          sorter: true,
          filter: true,
          filterType: 'input'
          // render: props => {
          //   return (
          //     <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
          //       {this.createDictText(props.row.isAccessory, '1004')}
          //     </el-tag>
          //   );
          // }
        },
        {
          title: '维修电动汽车标识',
          dataIndex: 'repairVehicleMark',
          sorter: true,
          filter: true,
          filterType: 'input'
          // render: props => {
          //   return (
          //     <el-tag type={props.row.isAccessory === 10041001 ? 'success' : 'primary'} close-transition>
          //       {this.createDictText(props.row.isAccessory, '1004')}
          //     </el-tag>
          //   );
          // }
        }
      ];
    },
    // 查询全部单位信息(翻译用)
    async queryAllUnitCode() {
      let res = await queryUnitCode();
      if (res.resultCode == 200) {
        let obj = {};
        res.data.map(item => {
          obj[item.UNIT_CODE] = item.UNIT_NAME;
        });
        this.unitCodeData = obj;
      }
    },
    async getBrand() {
      const res = await getBrand();
      this.topFilterList.find(item => item.fieldName == 'brand').itemList = res.data.map(x => ({ text: x.BRAND_NAME, value: x.BRAND_CODE + '' }));
      this.topFilterList.find(x => x.fieldName === 'brand').initialValue = res.data.find(item => item.BRAND_NAME == '奥迪').BRAND_CODE + '';
    },
    async queryDefaultPa() {
      let res = await findAllRepair();
      let brandList = await getBrand();
      for (let i = 0; i < brandList.data.length; i++) {
        if (brandList.data[i].BRAND_CODE == res.data['1004']) {
          this.topFilterList[0].initialValue = brandList.data[i].BRAND_CODE;
        }
      }
    },
    handleTableFilterCollapse() {
      console.log('高度改变', this.$refs.table.EXECUTE_RESET_HEIGHT);
      this.$nextTick(() => {
        this.$refs.table.EXECUTE_RESET_HEIGHT();
      });
    },
    addHandle() {
      this.formData = {};
      this.handleType = 'add';
      this.showHandler();
    },
    editHandle(row) {
      this.handleType = 'edit';
      this.formData = row;
      this.showHandler();
    },
    showHandle(row) {
      this.handleType = 'show';
      this.formData = row;
      this.showHandler();
    },
    // 点击搜索或者重置
    changeHandle(val) {
      if (!(!!(val.mainGroupNo && val.mainGroupNo.length > 1) || !!(val.partNo && val.partNo.length > 1))) {
        return notifyAction('请至少输入两位主组号或配件代码', 'warning');
      }
      this.fetchParams.xhrAbort = true;
      this.fetchParams = Object.assign(this.fetchParams, {
        xhrAbort: false,
        ...val,
        begin: val.begin ? val.begin.split(' ')[0] : '',
        end: val.end ? val.end.split(' ')[0] : ''
      });
    },
    showHandler() {
      this.dialogTitle = `${this.conf[this.handleType]}配件基本信息`;
      this.visible = true;
    },
    closeHandler(val, type) {
      this.visible = val;
      if (type === 'refresh') {
        // 重新加载
        this.fetchParams = { ...this.fetchParams };
      }
    },
    // 点击查看替换件
    showReplacePart(e) {
      this.rowDataPartNo = e.partNo;
      this.rowDataOptionNo = e.optionNo;
      this.replacePartDialogVisible = true;
    },
    // 点击选中table行项
    handleTableRowSelect(e) {
      this.selectedRowData = e;
    },
    // 点击复制按钮
    copyHandler() {
      if (this.selectedRowData.length) {
        this.handleType = 'add';
        this.formData = this.selectedRowData[0];
        this.showHandler();
      } else {
        notifyAction('请选择需要复制的配件', 'warning');
      }
    },
    // 点击r3价格下发
    showR3Price() {
      this.r3PriceDownloadVisible = true;
    },

    // 点击统一调整抽屉弹出
    adjustment() {
      this.adjustmentVisible = true;
    },
    // 导出处理函数
    handleExportFun(row) {
      row.updatedAt = row.updatedAt ? row.updatedAt.split('T')[0] : '';
      row.createdAt = row.createdAt ? row.createdAt.split('T')[0] : '';
    },
    outExe() {
      this.$confirm('此操作将导出excel文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.exportLoading = true;
        partExport(this.fetchParams).then(res => {
          console.log(res, '配件基本信息');
          exportExcelFile(res.data, '配件基本信息');
          this.exportLoading = false;
        });
      });
    }
  }
};
</script>
